import axios from 'axios'

export default function request(config:any) {
    const instance = axios.create({
        // baseURL:"http://www.zydz.icu:3009/fts/",
        baseURL:"http://localhost:3009/fts/",
        method:"post",
    })
    instance.interceptors.request.use(
        config => {
            if(sessionStorage.getItem("user") !== null){
                if(config.url !== "user/login" && config.url !== "user/userEmailCode" && config.url !== "good/info/code"){
                    config.data = Object.assign({},config.data,
                        {doName:(JSON.parse(sessionStorage.getItem("user") as any))[0].userName})
                }
            }
            return config  // 对config处理完后返回，下一步将向后端发送请求
        },
        error => {  // 当发生错误时，执行该部分代码
            // console.log(error); //调试用
            return Promise.reject(error)
        }
    )
    return instance(config)
}
